﻿using System.Collections.ObjectModel;
using System.Reactive;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaApplication1.Models;
using AvaloniaApplication1.ViewModels;

namespace AvaloniaApplication1.Views
{
    public class TestTreeViewWindow : Window
    {
        private SignTreeModel _mSignTreeModel= new SignTreeModel();

        public TestTreeViewWindow()
        {
            this.InitializeComponent();
            //SignTreeModel signTreeModel=new SignTreeModel();
            //this.DataContext = signTreeModel;
            TreeView treeView= this.FindControl<TreeView>("treeView");
            TreeView testTree = this.FindControl<TreeView>("testTree");
            
            for (int i = 0; i < 1; i++)
            {
                SignTreeModel signTreeModel=new SignTreeModel();
                _mSignTreeModel.Children.Add(signTreeModel);
                for (int j = 0; j < 10; j++)
                {
                    SignTreeModel child = new SignTreeModel() {Name = j.ToString()};
                    signTreeModel.Children.Add(child);
                    for (int k = 0; k < 10; k++)
                    {
                        child.Children.Add(new SignTreeModel(){Name = $"{i}+{j}+{k}"});
                    }
                }
            }
            
            //treeView.DataContext = signTreeModel;
            this.DataContext = _mSignTreeModel;
#if DEBUG
            //this.AttachDevTools();
#endif
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }
    }

    public class TestTreeVM:ViewModelBase
    {
        public TestTreeVM()
        {
            for (int i = 0; i < 1; i++)
            {
                SignTreeModel signTreeModel = new SignTreeModel();
                _mSignTreeModel.Children.Add(new SignTreeModel() { Name = i.ToString() });
                for (int j = 0; j < 10; j++)
                {
                    signTreeModel.Children.Add(new SignTreeModel() { Name = j.ToString() });
                }
            }
        }

        private SignTreeModel _mSignTreeModel = new SignTreeModel();

        private ObservableCollection<SignTreeModel> Tree=new ObservableCollection<SignTreeModel>();
    }
}
